package com.adaydayup.week_1017;

import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;

/*
239 滑动窗口最大值
  1 3 -1 -3 5 3 6 7   k=3
  3 3 5 5 6 7
 */
public class WinMax {
    public static int[] method(int[] arr, int k) {
        int len = arr.length;
        int[] ans=new int[len-k+1];
        int max = -10000;
        for (int i = 0; i <= len - k; i++) {
            for (int j = i; j < i+k; j++) {
                max = Math.max(max, arr[j]);
            }
            ans[i]=max;
            max = -10000;
        }
        return ans;
    }

    public static void main(String[] args) {
        int[] arr={1,3,-1,-3,5,3,6,7};
        int[] arr2={1,-1};
        int[] res = method(arr2, 1);
        int[] res2 = method(arr, 3);
        System.out.println(Arrays.toString(res2));
        System.out.println(Arrays.toString(res));
    }



}
